import { getListInfo, Article ,resourceAlter} from "./type";
import service from "@/utils/request";
import { AxiosPromise } from "axios";

const { resourceService } = service;
/**
 * 管理员获取列表
 *
 */
export function getResource(data: getListInfo): AxiosPromise<any> {
  return resourceService({
    url: "/resource/instrument/managerGetList",
    method: "get",
    params: data,
  });
}

/**
 * guan修改
 */
export function updatainfo(data: Article): AxiosPromise<any> {
  return resourceService({
    url: "/resource/instrument/updateByManager",
    method: "put",
    data: data,
  });
}

export function deleteAdmin(ids: number[]): AxiosPromise<any> {
  return resourceService({
    url: "/resource/instrument/delete/" + ids.join(","),
    method: "delete",
  });
}

/**
 * 管理员获取详情
 */
export function getDetail(id: number): AxiosPromise<any> {
  return resourceService({
    url: "/resource/instrument/managerGetById/" + id,
    method: "get",
  });
}

/**
 * 管理员审核
 */

export function examine(id?: number, status?: number): AxiosPromise<any> {
  return resourceService({
    url: "/resource/instrument/audit/" + id + "/" + status,
    method: "put",
  });
}

/**
 * 管理员下载资源
 */

export function downloadResource(id: number): AxiosPromise<any> {
  return resourceService({
    url: "/resource/instrument/caretakerDownLoad/" + id,
    method: "get",
  });
}

/**
 * 获取一级分类
 */	
export function getType1(): AxiosPromise<any> {
	return resourceService({
		url: "/resource/resourceType/getLevel1",
		method: "get",
	});
}


/**
 * 管理员修改资源
 */

export function resourceUpdate(resource: resourceAlter): AxiosPromise<any> {
  return resourceService({
    url: "/resource/instrument/updateByManager",
    method: "put",
		data:resource,
});
}

/**
 * 获取审核
 */

export function getStatus(): AxiosPromise<any> {
  return resourceService({
    url: "/resource/status",
    method: "get",
});
}
